@extends('layouts.app')

@section('title', '添加管理员')

@section('css-import')
<style type="text/css">
.form-input-control{
	margin-bottom: 20px;
}
.loadCardBackground{
	width: 350px;
	display: block;
	margin:15px;
}
.fancy-checkbox-re{
	display: inline-block;
}
.fancy-checkbox-paren{
	display: block;
    font-weight: normal;
}
</style>
@endsection

@section('content-fluid')

<div class="panel">
	<div class="panel-heading">
		<h3 class="panel-title">添加管理员</h3>
	</div>
	<div class="panel-body">
		<form action="/system/create/action" method="post" id="createIdPower">
			<select class="form-control" name="region">
				<option value="0">选择角色</option>
				<option value="1" {{$region=='1'?'selected=selected':''}}>管理员</option>
				<option value="2" {{$region=='2'?'selected=selected':''}}>普通管理</option> 
				<option value="3" {{$region=='3'?'selected=selected':''}}>企业商户</option>
			</select>
			<br>
			<input type="text" name="name" class="form-control" value="{{$userinfo->admin_name ?? ''}}" autocomplete="off" placeholder="管理员姓名或别称">
			<br>
			<input type="text" name="tel" class="form-control" value="{{$userinfo->admin_tel ?? ''}}" autocomplete="off" placeholder="手机号">
			<br>
			<input type="password" name="setpassword" class="form-control" placeholder="设定密码" autocomplete="off">
			<br>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power" value="*" {{in_array('*',$power)?'checked':''}}>
					<span>所有权限</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/" {{in_array('/',$power)?'checked':''}}>
					<span>数据统计</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/finance">
					<span>财务收支</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/manageCard" {{in_array('/manageCard',$power)?'checked':''}}>
					<span>饭卡管理</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/mealCardDesign" {{in_array('/mealCardDesign',$power)?'checked':''}}>
					<span>创建饭卡</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/cardSellorder" {{in_array('/cardSellorder',$power)?'checked':''}}>
					<span>出售订单</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/card/gift" {{in_array('/card/gift',$power)?'checked':''}}>
					<span>发放饭卡</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/redpack/list" {{in_array('/redpack/list',$power)?'checked':''}}>
					<span>分享红包记录</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/manageCoupon" {{in_array('/manageCoupon',$power)?'checked':''}}>
					<span>卡券管理</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/coupon/release" {{in_array('/coupon/release',$power)?'checked':''}}>
					<span>发布卡券</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/coupon/order/list" {{in_array('/coupon/order/list',$power)?'checked':''}}>
					<span>卡券出售订单</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/coupon/shop/list" {{in_array('/coupon/shop/list',$power)?'checked':''}}>
					<span>卡券商户</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/coupon/extract/list" {{in_array('/coupon/extract/list',$power)?'checked':''}}>
					<span>卡券商户提现</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/get/circle/list" {{in_array('/get/circle/list',$power)?'checked':''}}>
					<span>商圈管理</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/get/circle/view" {{in_array('/get/circle/view',$power)?'checked':''}}>
					<span>可视商圈</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/shopList" {{in_array('/shopList',$power)?'checked':''}}>
					<span>商户管理</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/userIdentifiList" {{in_array('/userIdentifiList',$power)?'checked':''}}>
					<span>商户认证</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/extractList" {{in_array('/extractList',$power)?'checked':''}}>
					<span>商户提现</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/orderListAll" {{in_array('/orderListAll',$power)?'checked':''}}>
					<span>商户订单</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/company/take" {{in_array('/company/take',$power)?'checked':''}}>
					<span>申请提现操作</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/createQrcode" {{in_array('/createQrcode',$power)?'checked':''}}>
					<span>预生成二维码</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/userAll" {{in_array('/userAll',$power)?'checked':''}}>
					<span>用户管理</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/delivery/order" {{in_array('/delivery/order',$power)?'checked':''}}>
					<span>配送订单</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/feedback" {{in_array('/feedback',$power)?'checked':''}}>
					<span>用户反馈</span>
				</label>
			</label>
			<label class="fancy-checkbox-paren">
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/homePageEdit" {{in_array('/homePageEdit',$power)?'checked':''}}>
					<span>小程序内容修改</span>
				</label>
				<label class="fancy-checkbox-re fancy-checkbox">
					<input type="checkbox" name="power[]" value="/edit/official" {{in_array('/edit/official',$power)?'checked':''}}>
					<span>官网内容修改</span>
				</label>
			</label>
			<br>
			<label class="fancy-radio">
				<input name="status" value="1" type="radio" {{$status==1?'checked':''}}>
				<span><i></i>立即生效</span>
			</label>
			<label class="fancy-radio">
				<input name="status" value="0" type="radio" {{$status==0?'checked':''}}>
				<span><i></i>暂不生效</span>
			</label>
			<input type="hidden" name="admin_id" value="{{empty($_GET['admin_id'])?'':$_GET['admin_id']}}">
			<br><br>
			<div class="row">
				<div class="col-md-2">
					<button type="submit" class="btn btn-success btn-block">确认添加</button>
				</div>
			</div>
		</form>
	</div>
</div>
@endsection

@section('js-import')
<script type="text/javascript" src="{{config('app.inlet_src')}}/a/js/design.js"></script>
@endsection

@section('js-write')
<script type="text/javascript">
	$('select[name="region"]').change(function(e){
		if(e.target.value==3){
			$('input[type="checkbox"]').attr('disabled',true).attr('checked',false)
			$('input[name="name"]').attr('placeholder','企业商户名称')
		}else{
			$('input[type="checkbox"]').attr('disabled',false)
			$('input[name="name"]').attr('placeholder','管理员姓名或别称')
		}
	})
	var CouponSendParam = {
	    'dataType':'json',
	    'beforeSubmit':CouponBefore,
	    'success':CouponResponse,
	    'error':toutiaoError,
	};
	function CouponBefore(formData, jqForm, options){
	    
	}
	function CouponResponse(response) {
	    if(response.success){
	        setTimeout(function(){
	            location.href = '/system/list';
	        },2000);
	        toastr.success(response.message);
	    }else{
	        toastr.error('修改失败，请联系开发人员！');
	    }
	}

	function toutiaoError(XMLHttpRequest, textStatus, errorThrown) {
		if(XMLHttpRequest.status==422){
			var RegError = XMLHttpRequest.responseJSON.errors;
			for(var o in RegError){
				for (var i = 0; i < RegError[o].length; i++) {
					toastr.error(RegError[o][i]);
				}
			}
		}
	}
	ajaxForm_('#createIdPower', CouponSendParam);
</script>
@endsection